//
//  RootTableViewCell.m
//  WangI
//
//  Created by 刘珊珊 on 15/11/24.
//  Copyright (c) 2015年 刘珊珊. All rights reserved.
//

#import "RootTableViewCell.h"
#import "UIImageView+WebCache.h"

@implementation RootTableViewCell

-(void)dealloc{
    [_imageV release];
    [_titltLabel release];
    [_digestLabel release];
    [_replyCountLabel release];
    [super dealloc];
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        _imageV = [[UIImageView alloc]init];
//        _imageV.backgroundColor = [UIColor redColor];
        
        _titltLabel = [[UILabel alloc]init];
//        _titltLabel.backgroundColor = [UIColor grayColor];
        _titltLabel.font = [UIFont boldSystemFontOfSize:17];
        
        _digestLabel = [[UILabel alloc]init];
//        _digestLabel.backgroundColor = [UIColor greenColor];
        _digestLabel.numberOfLines = 2;
        _digestLabel.font = [UIFont systemFontOfSize:15];
        
        _replyCountLabel = [[UILabel alloc]init];
        _replyCountLabel.font = [UIFont systemFontOfSize:15];
//        _replyCountLabel.backgroundColor = [UIColor blueColor];
        
        [self addSubview:self.imageV];
        [self addSubview:self.titltLabel];
        [self addSubview:self.digestLabel];
        [self addSubview:self.replyCountLabel];
    }
    return self;
}


- (void)layoutSubviews {
    [super layoutSubviews];
    _imageV.frame = CGRectMake(10, 10, 110, 90);
    _titltLabel.frame = CGRectMake(130, 10, self.frame.size.width - 130 - 20, 30);
    _digestLabel.frame = CGRectMake(130, 45, self.frame.size.width - 130 - 20, 60);
    _replyCountLabel.frame = CGRectMake(self.frame.size.width - 50, 75, 55, 30);
  
}


-(void)setHeadModel:(HeadlineModel *)headModel{
    if (_headModel != headModel) {
        [_headModel release];
        _headModel = [headModel retain];
    }
        [self.imageV sd_setImageWithURL:[NSURL URLWithString:headModel.imgsrc]];
        self.titltLabel.text = headModel.title;
        self.digestLabel.text = headModel.digest;
        self.replyCountLabel.text = [NSString stringWithFormat:@"%ld",[headModel.replyCount integerValue]];
    
}

- (void)awakeFromNib {
    // Initialization code}
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
